let path = require('path');
let webpack = require('webpack');
// const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
  mode : 'production', // development | production
  entry : {
    'timer/monitor/t' : ['./comps/timer/monitor/t.js'],

    'board_2018/monitor/b2018' : ['./comps/board_2018/monitor/b2018.js'],
    'board_2018/monitor/b169' : ['./comps/board_2018/monitor/b169.js'],
    'board_2018/monitor/b43' : ['./comps/board_2018/monitor/b43.js'],
    'board_2018/monitor/programme2019' : ['./comps/board_2018/monitor/programme2019.js'],

    'danmaku/monitor/danmaku' : ['./comps/danmaku/monitor/danmaku.js'],
    'danmaku/monitor/danmaku_arcade' : ['./comps/danmaku/monitor/danmaku_arcade.js'],
    'danmaku/monitor/fallen_knight' : ['./comps/danmaku/monitor/fallen_knight.js'],

    'flight/monitor/universe_pictorial' : ['./comps/flight/monitor/universe_pictorial.js'],

    'mega_sphere/monitor/mega_sphere' : ['./comps/mega_sphere/monitor/mega_sphere.js'],
    'mega_sphere/monitor/mega_sphere_4' : ['./comps/mega_sphere/monitor/mega_sphere_4.js'],

    'name_tag/monitor/tag_2019' : ['./comps/name_tag/monitor/tag_2019.js'],

    'rakuen/monitor/ribbons' : ['./comps/rakuen/monitor/ribbons.js'],

    'rockman/monitor/rock_select' : ['./comps/rockman/monitor/rock_select.js'],

    'shaders/monitor/shaders' : ['./comps/shaders/monitor/shaders.js'],

    'snow_bros/monitor/snow_bros' : ['./comps/snow_bros/monitor/snow_bros.js'],

    // tools
    'tools/monitor/path_editors' : ['./comps/tools/monitor/path_editors.js'],

    // TODO and more
  },
  output : {
    filename : '[name].js',
    path : path.resolve(__dirname, 'dist-comp'),
    library : 'chunk',
    libraryTarget : 'var' // 默认就是 var
  },
  plugins : [
    new webpack.DllPlugin({
      name : 'chunk', // 这个 name 要和上面的 library 相等
      path : path.resolve(__dirname, 'dist-comp', '[name]-manifest.json'),
      context : __dirname
    })
  ],
  externals : {
    vue : 'Vue'
  },
  module : {
    rules : [
      {
        test : /\.js$/,
        exclude : /node_modules/,
        use : [
          {
            loader : 'babel-loader',
            options : {
              presets : [
                '@babel/preset-env'/*, '@babel/preset-react'*/
              ],
              plugins : [
                '@babel/plugin-proposal-class-properties'
              ]
            }
          }
        ]
      }
    ]
  },
};
